<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <h1 class="count">0</h1>
  <button class="increament">+1</button>
  <button class="decreament">-1</button>
  <script>
    // 1.获取元素
    const countEl = document.querySelector(".count")
    const increEl = document.querySelector(".increament")
    const decreEl = document.querySelector(".decreament")

    // 2.定义变量
    let counter = 100
    countEl.innerHTML = counter

    // 3.监听按钮的点击
    increEl.addEventListener('click', () => {
      counter += 1
      countEl.innerHTML = counter
    })
    decreEl.addEventListener('click', () => {
      counter -= 1
      countEl.innerHTML = counter
    })

  </script>
</body>
</html>